<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    {{template "link/customer/link.html" . }}
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
    <style>
        .item-head {
            height: 80px;
            border: 1px solid #e2e2e2;
            background: #eaf8ff;
        }

        .order-item {
            margin-bottom: 30px;
        }

        .head-item {
            margin-right: 100px;
        }

        .head-item-left {
            float: left;
        }

        .head-item-right {
            float: right;
        }
    </style>
</head>
<body>

{{template "link/customer/nav.html" . }}
{{template "link/customer/header.html" .}}
<div class="content content-nav-base shopcart-content">

    <div class="cart w1200">
        <div class="cart-table-th">
            <div class="th th-item">
                <div class="th-inner">
                    商品
                </div>
            </div>
            <div class="th th-price">
                <div class="th-inner">
                    单价
                </div>
            </div>
            <div class="th th-amount">
                <div class="th-inner">
                    数量
                </div>
            </div>
            <div class="th th-sum">
                <div class="th-inner">
                    实付款
                </div>
            </div>
            <div class="th th-sum">
                <div class="th-inner">
                    状态
                </div>
            </div>
        </div>
        <div class="OrderList">
            {{range .Orders}}
                <div class="order-content order-item" id="list-cont">
                    <div class="item-head">
                        <div style="height: 20px">
                            <div class="head-item-left">
                                <span class="head-item"> 下单时间 {{.OrderCreateTime}} </span>
                                <span class="head-item">订 单 号 {{.OrderId}}</span>
                            </div>
                            <div class="head-item-right">
                                <span class="head-item">总价 : {{.OrderSumPrices}}</span>
                            </div>
                        </div>
                        <div style="height: 25px; margin: 5px 0;">
                            <div class="head-item-left">
                                <span class="head-item"> 联系人 {{.OrderUserName}} </span>
                            </div>
                            <div class="head-item-right">
                                <span class="head-item"> 联系人电话 {{.OrderUserPhone}}</span>
                            </div>
                        </div>
                        <div style="height: 25px;">
                            <div class="head-item-left">
                                <span>送往{{.OrderProvince }}  {{.OrderCity}} {{.OrderArea}}  {{.OrderAddress}}</span>
                            </div>
                            <div class="head-item-right">
                                {{if eq .OrderStatus "已下单"}}
                                    <span style="color: red;margin-right: 120px">待发货</span>
                                {{else}}
                                    {{if eq .OrderStatus "已发货"}}
                                        <button style="height: 24px;line-height: 0px;"
                                                class="layui-btn layui-btn-danger"
                                                value="{{.OrderId}}" id="confirm-received">确认收货
                                        </button>
                                    {{else}}
                                        {{if eq .OrderStatus "需添加收件信息"}}
                                            <span style="color: red;margin-right: 120px">未支付</span>
                                        {{else}}
                                            <span style="color: red;margin-right: 120px">已收货</span>
                                        {{end}}
                                    {{end}}
                                {{end}}
                            </div>
                        </div>
                    </div>
                    {{$orderStatus := .OrderStatus}}
                    {{$OrderIdTemp := .OrderId}}
                    {{range .OrderItems}}
                        <div>
                            <ul class="item-content layui-clear">
                                <li class="th th-item">
                                    <div class="item-cont">
                                        <a href="/customer/goodDetail?id={{.ItemGoodsId}}"><img
                                                    src="/static/upload/good/{{.GoodItem.GoodUrl}}" alt=""></a>
                                        <div class="text">
                                            <div class="title">{{.GoodItem.GoodName}}</div>
                                        </div>
                                    </div>
                                </li>
                                <li class="th th-price">
                                    <span class="th-su">{{.ItemPrices}}</span>
                                </li>
                                <li class="th th-amount">
                                    <div class="box-btn layui-clear">
                                        <input type="text" hidden="hidden" value="{{.GoodItem.GoodId}}" class="goodId">
                                        <input class="Quantity-input" type="" name="" value="{{.ItemNums}}"
                                               disabled="disabled">
                                    </div>
                                </li>
                                <li class="th th-sum">
                                    <span class="sum">{{.ItemSum}}</span>
                                </li>
                                <li class="th th-price">
                                    {{if eq $orderStatus "需添加收件信息"}}
                                        <span class="sum"><a
                                                    href="/customer/orderEx?orderId={{$OrderIdTemp}}">{{$orderStatus}}</a></span>
                                    {{else}}
                                        <span class="sum">{{$orderStatus}}</span>
                                    {{end}}
                                </li>
                            </ul>
                        </div>
                    {{end}}
                </div>
            {{end}}

        </div>


    </div>
</div>

<script type="text/javascript">
    layui.config({
        base: '/static/js/util/' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['mm', 'jquery', 'element', 'car'], function () {
        var $ = layui.jquery
        var layer = layui.layer
        $("#confirm-received").on('click', function () {
            var orderId = $(this).val()
            var item = "orderId=" + orderId
            layer.open({
                content: '确认发货',
                yes: function () {
                    $.ajax({
                            url: "/customer/receiveOrder",
                            method: 'post',
                            data: item,
                            dataType: 'json',
                            contentType: "application/x-www-form-urlencoded;charset=UTF-8",
                            success: function (res) {
                                console.log(res);
                                if (res.code == 0) {
                                    layer.alert("确认收货")
                                } else {
                                    layer.alert("失败")
                                }
                            }
                        }
                    )
                }
            })
        });
    });
</script>
</body>
</html>